package com.app.system.controller;

import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.AjaxResult;
import com.app.common.core.page.TableDataInfo;
import com.app.common.enums.BusinessType;
import com.app.common.utils.poi.ExcelUtil;
import com.app.system.domain.UserPhoto;
import com.app.system.service.IUserPhotoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 储存用户的证件照制作历史Controller
 * 
 * @author app
 * @date 2025-11-05
 */
@RestController
@RequestMapping("/image/image")
public class UserPhotoController extends BaseController
{
    @Autowired
    private IUserPhotoService userPhotoService;

    /**
     * 查询储存用户的证件照制作历史列表
     */
    @PreAuthorize("@ss.hasPermi('image:image:list')")
    @GetMapping("/list")
    public TableDataInfo list(UserPhoto userPhoto)
    {
        startPage();
        List<UserPhoto> list = userPhotoService.selectUserPhotoList(userPhoto);
        return getDataTable(list);
    }

    /**
     * 导出储存用户的证件照制作历史列表
     */
    @PreAuthorize("@ss.hasPermi('image:image:export')")
    @Log(title = "储存用户的证件照制作历史", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UserPhoto userPhoto)
    {
        List<UserPhoto> list = userPhotoService.selectUserPhotoList(userPhoto);
        ExcelUtil<UserPhoto> util = new ExcelUtil<UserPhoto>(UserPhoto.class);
        util.exportExcel(response, list, "储存用户的证件照制作历史数据");
    }

    /**
     * 获取储存用户的证件照制作历史详细信息
     */
    @PreAuthorize("@ss.hasPermi('image:image:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(userPhotoService.selectUserPhotoById(id));
    }

    /**
     * 新增储存用户的证件照制作历史
     */
    @PreAuthorize("@ss.hasPermi('image:image:add')")
    @Log(title = "储存用户的证件照制作历史", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UserPhoto userPhoto)
    {
        return toAjax(userPhotoService.insertUserPhoto(userPhoto));
    }

    /**
     * 修改储存用户的证件照制作历史
     */
    @PreAuthorize("@ss.hasPermi('image:image:edit')")
    @Log(title = "储存用户的证件照制作历史", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UserPhoto userPhoto)
    {
        return toAjax(userPhotoService.updateUserPhoto(userPhoto));
    }

    /**
     * 删除储存用户的证件照制作历史
     */
    @PreAuthorize("@ss.hasPermi('image:image:remove')")
    @Log(title = "储存用户的证件照制作历史", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(userPhotoService.deleteUserPhotoByIds(ids));
    }
}
